package com.pony.controller;

import com.pony.entity.Yyxts;
import com.pony.service.YyxtsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/yyxts")
@Controller
public class YyxtsController {

    @Autowired
    private YyxtsService yyxtsService;


    @RequestMapping("/getAllYyxts")
    public String getAllYyxts(Model model) {
        List<Yyxts> list = yyxtsService.getAll();
        model.addAttribute("list", list);
        return "yyxts";
    }

    @RequestMapping("/delYyxts")
    public String delYyxts(int id){
        yyxtsService.delYyxts(id);
        return "redirect:/yyxts/getAllYyxts.do";
    }

    @RequestMapping("/toTj")
    public String toTj(Model model) {
        List<Yyxts> yyxtsList = yyxtsService.getAll();
        model.addAttribute("yyxtsList", yyxtsList);
        return "yyxtstj";
    }

    @RequestMapping("/addYyxts")
    public String addYyxts(Yyxts yyxts) {
        yyxtsService.addYyxts(yyxts);
        return "redirect:/yyxts/getAllYyxts.do";
    }
}
